import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import dts from "rollup-plugin-dts";
import commonjs from '@rollup/plugin-commonjs'
import path from 'path'


/**
 * @type {import('rollup').RollupOptions}
 */
const rollupOption = [
    // {
    //     external: ['vue', 'VueEsm'],
    //     plugins: [
    //         json(),
    //         nodeResolve(),
    //         typescript(),
    //         commonjs(),
    //     ],
    //     input: 'packages/index.ts',
    //     output: {
    //         sourcemap: false,
    //         format: 'es',
    //         file: path.resolve(__dirname, `dist/one-bundle-es/bundle.esm.js`),
    //     },
        
    // },
    // {
    //     external: ['vue', 'VueEsm'],
    //     plugins: [
    //         dts(),
    //     ],
    //     input: 'packages/index.ts',
    //     output: {
    //         format: 'es',
    //         file: path.resolve(__dirname, `dist/one-bundle-es/bundle.esm.d.ts`),
    //     },
    // },

    // 保留模块
    {
        external: ['vue', 'VueEsm'],
        plugins: [
            json(),
            nodeResolve(),
            typescript(),
            commonjs(),
        ],
        input: 'packages/core/index.ts',
        output: {
            format: 'es',
            dir: path.resolve(__dirname, 'dist'),
            preserveModules: true,
        },
    },
    {
        external: ['vue', 'VueEsm'],
        plugins: [
            dts()
        ],
        input: 'packages/core/index.ts',
        output: {
            format: 'es',
            dir: path.resolve(__dirname, 'dist'),
            // preserveModules: true,
            // preserveModulesRoot: path.resolve(__dirname, 'dist'),
        },
    },
    
]

export default rollupOption